package com.movitech.mobile.cz.base.modules.config;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 采购流程类型
 *
 * @author julius
 * @since 2018-03-16
 */
public enum PurchasePlanStatusEnum {
    PURCHASE_PLAN_STATUS_1("待确认", 1),
    PURCHASE_PLAN_STATUS_2("确认中", 2),
    PURCHASE_PLAN_STATUS_3("已确认", 3),
    PURCHASE_PLAN_STATUS_4("进行中", 4),
    PURCHASE_PLAN_STATUS_5("已完成", 5);

    private String desc;
    private int code;

    private PurchasePlanStatusEnum(String desc, int code) {
        this.desc = desc;
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public static PurchasePlanStatusEnum getByCode(int code) {
        List<PurchasePlanStatusEnum> result = Arrays.stream(PurchasePlanStatusEnum.values()).filter(item -> code == item.getCode()).collect(Collectors.toList());
        if (result != null && result.size() > 0) {
            return result.get(0);
        }
        return null;
    }
}
